﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cz.muni.fi.pb138.IO
{
    class ImportExportManager
    {
		/// <summary>
		/// Register all the existing implementations of factories here
		/// </summary>
        public ImportExportManager()
        {
            this.ioFactories = new List<IIOFactory>();
            this.ioFactories.Add(new Implementation.ODF.IOFactoryODF());
        }

		/// <summary>
		/// the list of all existing factories to import/export media to/from
		/// </summary>
        public List<IIOFactory> ioFactories;
		/// <summary>
		/// TODO: this is an ERROR - not corresponding to the specification. The manager should have
		/// NO control over what file is the specific factory using
		/// </summary>
        public string FileName { get; set; }

		/// <summary>
		/// loads Media from the specific factory
		/// TODO: the factory should be selected from the list and passed as an argument.
		/// for there is just one implementation at the moment, this definition meets
		/// the requirements
		/// </summary>
		/// <returns>list of media retrieved by the factory</returns>
        public IList<Media> loadData()
        {
            return this.ioFactories[0].importData(this.FileName);
        }

		/// <summary>
		/// saves the Media given by the collection in <c>list</c> parameter using a specific factory
		/// TODO: the specific factory should be passed to the method determining which factory shall be used.
		/// since there is just one implementation of an <c>IIOFactory</c> at the moment, this solution
		/// meets the requirements
		/// </summary>
		/// <param name="list">the collection of <c>Media</c> classes to be stored by a given factory</param>
        public void saveData(IList<Media> list)
        {
            this.ioFactories[0].exportData(list, this.FileName);
        }
    }
}
